<?php

class Pagamento extends AppModel {

    var $name = 'Pagamento';
    var $displayField = 'descricao';
    //The Associations below have been created with all possible keys, those that are not needed can be removed

    var $belongsTo = array(
        'Categoria' => array(
            'className' => 'Categoria',
            'foreignKey' => 'categoria_id',
            'conditions' => '',
            'fields' => '',
            'order' => ''
        )
    );
    
    /**
     * Utilizado para formatar a data depois do filtro
     */
    function afterFind($results) {

        if ($results) {
            
            foreach ($results as $key => $val) {

                if (isset($val['Pagamento']['data'])) {
                    $results[$key]['Pagamento']['data'] = $this->dateFormate($val['Pagamento']['data']);
                }
            }
        }
        return $results;
    }
    
    /**
     * Utilizado para formatar a data antes de salvar
     */
    function beforeSave() {

        if ($this->data) {
            
            foreach ($this->data as $val) {

                if (isset($val['data'])) {
                    $this->data['Pagamento']['data'] = $this->dateFormate($val['data']);
                }
            }
        }

        return $this->data;
    }

}

?>